package com.lingjtx.common.core.util;

import java.util.List;

/**
 * 公共常用命令集，此类搭配 CommandExecutor 类使用
 * List<String> command = CommonCommandSet.CONVERT_DOCUMENT.build("docx", outputDir, inputPath);
 * CommandExecutor.CommandResult result = CommandExecutor.execute(command, true, 10000);
 */
public enum CommonCommandSet {

    // LibreOffice 文档转换
    CONVERT_DOCUMENT {
        @Override
        public List<String> build(Object... args) {
            String filetype = (String) args[0]; // docx pdf 等参数
            String outputPath = (String) args[1];
            String inputPath = (String) args[2];
            return List.of("soffice", "--headless", "--convert-to", filetype, "--outdir", outputPath, inputPath);
        }
    },

    // PDF 转图片示例（需 imagemagick 或 pdftoppm）
    CONVERT_PDF_TO_PNG {
        @Override
        public List<String> build(Object... args) {
            String pdfPath = (String) args[0];
            String imageDir = (String) args[1];
            return List.of("pdftoppm", "-png", pdfPath, imageDir + "/output");
        }
    },

    // Shell 脚本执行
    EXECUTE_SHELL {
        @Override
        public List<String> build(Object... args) {
            String scriptPath = (String) args[0];
            return List.of("sh", scriptPath);
        }
    };

    public abstract List<String> build(Object... args);
}
